using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Data.EntityClient;
using System.Data.Metadata.Edm;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Linq;
using System.Runtime;

namespace xiushen.Domain
{
    public interface IObjectContext : IDisposable
    {
        //All ObjectContext Members
        //-------------------------
        //void AcceptAllChanges();
        //void AddObject(string entitySetName, object entity);
        //void ApplyPropertyChanges(string entitySetName, object changed);
        //void AttachTo(string entitySetName, object entity);
        //void Attach(IEntityWithKey entity);
        //EntityKey CreateEntityKey(string entitySetName, object entity);
        //void DeleteObject(object entity);
        //void Detach(object entity);
        //object GetObjectByKey(EntityKey key);
        //void Refresh(RefreshMode refreshMode, IEnumerable collection);
        //void Refresh(RefreshMode refreshMode, object entity);
        //int SaveChanges();
        //int SaveChanges(bool acceptChangesDuringSave);
        //bool TryGetObjectByKey(EntityKey key, out object value);
        //DbConnection Connection { get; }
        //string DefaultContainerName { get; set; }
        //MetadataWorkspace MetadataWorkspace { get; }
        //ObjectStateManager ObjectStateManager { get; }
        //int? CommandTimeout { get; set; }
        string DefaultContainerName { get; set; }
        DbConnection Connection { get; }
        DbTransaction Transaction { get; set; }
        ObjectStateManager ObjectStateManager { get; }
        [CLSCompliant(false)]
        MetadataWorkspace MetadataWorkspace
        {
            [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
            get;
        }

        ObjectQuery<T> CreateQuery<T>(string path, params ObjectParameter[] parameters);

        void AddObject(string entitySetName, object entity);
        object GetObjectByKey(EntityKey key);
        bool TryGetObjectByKey(EntityKey key, out object value);

        void ApplyPropertyChanges(string entitySetName, object changed);
        int SaveChanges();
        void Refresh(RefreshMode refreshMode, object entity);

        void Detach(object entity);
        void Attach(IEntityWithKey entity);
        void DeleteObject(object entity);
        ObjectSet<TEntity> CreateObjectSet<TEntity>() where TEntity : class;
        ObjectResult<TElement> ExecuteStoreQuery<TElement>(string commandText, params object[] parameters);

        DbTransaction BeginTransaction(IsolationLevel isolationLevel);
        int ExecuteStoreCommand(string commandText, params object[] parameters);

    }
}